<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="UTF-8"/>
    <title sec:authentication="name"></title>
    <link rel="stylesheet" th:href="@{css/bootstrap.min.css}"/>
    <style type="text/css">
        body {
            padding-top: 50px;
        }

        .starter-template {
            padding: 40px 15px;
            text-align: center;
        }
    </style>
</head>
<body>
<div th:replace="navbar::navbar"></div>
<div class="container">
    <div class="starter-template">
        <div sec:authorize="isAuthenticated()">

            <p>Hello</p>
            <p>You have logged in.</p>
            <p>Your username is：<span sec:authentication="name"></span></p>

            <p>Your Role is：
                <span sec:authorize="hasRole('ROLE_ADMIN')">Administrator</span>
                <span sec:authorize="hasRole('ROLE_USER')">Normal User</span>
            </p>
        </div>

        <form th:action="@{/logout}" method="post">
            <input type="submit" class="btn btn-primary" value="Logout"/>
        </form>
        <div sec:authorize="hasRole('ROLE_ADMIN')">
            <form th:action="@{/user/list}" method="get">
                <input type="submit" class="btn btn-primary" value="List All Users"/>
            </form>
        </div>
    </div>


</div>
</body>
</html>